
public class CadastroCartao extends CadastroCartaoAbstrato {
	
	private Cartao cartoes[];

	private int quantCartoes;
	private final int TAM_ARRAY = 100;
	

	public CadastroCartao() {

		cartoes = new Cartao[TAM_ARRAY];
		this.quantCartoes = 0;
	}

	public void setCartoes(Cartao cartoes[]) {
		this.cartoes = cartoes;
	}

	public Cartao[] getCartoes() {
		return cartoes;
	}

	public void setQuantCartoes(int quantCartoes) {
		this.quantCartoes = quantCartoes;
	}

	public int getQuantCartoes() {
		return quantCartoes;
	}
	
	
	public boolean inserir(Cartao c) {

		if (c == null) {
			System.out.println("Objeto Cartao estar vazio");
			return false;

		}

		if (quantCartoes < TAM_ARRAY) {

			if (buscar(c.getCpf()) == null) {

				getCartoes()[quantCartoes] = c;
				quantCartoes++;
				return true;
			} else {

				System.out.println("CPF ja cadastrado");
				return false;
			}

		} else {

			System.out.println("Rep cheio");
			return false;
		}

	}

	public Cartao buscar(String Cpf) {

		for (int i = 0; i < getCartoes().length; i++) {
			if (getCartoes()[i] != null) {
				if (getCartoes()[i].getCpf().equals(Cpf)) {
					return getCartoes()[i];
				}

			}
		}
		return null;

	}
	
	public boolean remover(String numero) {

		for (int i = 0; i < getCartoes().length; i++) {

			if (getCartoes()[i].getNumero().equals(numero) ) {
				getCartoes()[i] = null;
				return true;

			}

		}
		return false;

	}

	public String Listar(){
		String resultado = "";
		
		for(int i = 0; i < getCartoes().length; i++){
			if(getCartoes()[i] != null){
				resultado += getCartoes()[i] + "\n";					
			}
		}
		return resultado;
	}
	
		

}
